updating oE subtract

subtract

include datetime.e -- (default namespace is datetime) 
public function subtract(datetime dt, atom qty, integer interval) 

Subtracts a number of intervals to a base datetime.

Parameters:
  1. dt : the base datetime
  2. qty : the number of intervals to subtract. It should be positive.
  3. interval : which kind of interval to subtract.
Returns:

A sequence, more precisely a datetime representing the new moment in time.

Comments:

Please see Constants for Date and Time for a reference of valid intervals.

See the function add for more information on adding and subtracting date intervals

Example 1:
include std/datetime.e 
 
datetime dt1 = now() 
? dt1 
datetime dt2 = subtract(dt1, 18, MINUTES) -- subtract 18 minutes from dt1 
? dt2 
dt2 = subtract(dt1, 7, MONTHS)   -- subtract 7 months from dt1 
? dt2 
dt2 = subtract(dt1, 12, HOURS)   -- subtract 12 hours from dt1 
? dt2 
Results:

{2019,9,8,3,10,13} (yours will vary)
{2019,9,8,2,52,13}
{2019,2,8,3,10,13}
{2019,9,7,15,10,13}

See Also:

add, diff

Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu